let initialstate = {
    residentId: null,
    residentDetail: {},
    WeightList: [],
    BloodSurgeList: [],
    BloodPressureList: [],
    HeartRateList: []
}
export default function WTreducer(state = initialstate, action: any) {
    // 1.深拷贝state,得到一个全新的state
    let newState = JSON.parse(JSON.stringify(state))


    // 2.匹配动作类型,对state进行对应的处理
    switch (action.type) {
        case "SAVE_RESIDENTID":
            newState.residentId = action.payload
            break;
        case "SAVE_DETAIL":
            return ({ ...newState, ...action.payload })
            // newState.residentDetail = action.payload
            break;
        case "SAVE_WEIGHTLIST":
            newState.WeightList = action.payload
            break;
        case "SAVE_BlOODSURGELIST":
            newState.BloodSurgeList = action.payload
            break;
        case "SAVE_BLOODPRESSURELIST":
            newState.BloodPressureList = action.payload
            break;
        case "SAVE_HEARTRATELIST":
            newState.HeartRateList = action.payload
            break;
        default:
            return state//注意:由于引用类型存储会丢失,所以得加上这个,具体原因:
            break;
    }

    // 3.返回处理后全新的state
    return newState
}